﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Ext.Net;
using System.Data;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnLogin_Click(object sender, DirectEventArgs e)
    {
        this.Window1.Hide();

        string template = "<br /><b>LOGIN UnSUCCESS</b><br /><br />Username: {0}<br />Password: {1}";
        string username = this.txtUsername.Text;
        string password = this.txtPassword.Text;

        SqliteHelper sqlite = new SqliteHelper();
        string sql = "select user from user where user='" + username + "' and pwd='" + password + "'";
        DataSet dr = SqliteHelper.ExecuteDataset(SqliteHelper.ConnectionString, System.Data.CommandType.Text, sql);
        if (dr != null && dr.Tables.Count > 0 && dr.Tables[0].Rows.Count > 0)
        {
            Common.WriteCookie("user", username);
            Response.Redirect("main.aspx");
        }
        else
        {
            this.lblMessage.Html = string.Format(template, username, password);
        }
    }
}